package com.myhouse.biz.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.myhouse.biz.HouseService;
import com.myhouse.biz.PhotoService;
import com.myhouse.dao.HouseDao;
import com.myhouse.dao.PhotoDao;
import com.myhouse.entity.House;
import com.myhouse.entity.Photo;
@Service
public class HouseServiceImpl implements HouseService{
	@Resource
	private HouseDao houseDao;
	@Resource
	private PhotoDao photoDao;

	@Override
	public List<House> houseTime(Integer did, Integer sid, Integer tid, String title, Integer startPage,
			Integer pageSize,String price,String updateTime,Integer price1,Integer price2) {
		return houseDao.houseTime(did, sid, tid, title, startPage, pageSize, price, updateTime,price1,price2);
	}

	@Override
	public House getByHouse(int id) {
		return houseDao.getByHouse(id);
	}

	@Override
	public void addHouse(House house,Photo photo) {
		houseDao.addHouse(house);
		photo.setFilename(house.getId()+".jpg");
		photo.setHourseId(house.getId());
		photo.setTitle(house.getPhoto().getTitle());
		photoDao.addPhoto(photo);
	}

	@Override
	public List<House> getNewHouse(int startNum,int num) {
		return houseDao.getNewHouse(startNum,num);
	}

	@Override
	public List<House> getPriceHouse(int num) {
		return houseDao.getPriceHouse(num);
	}

	@Override
	public int getRows(Integer did, Integer sid, Integer tid, String title, Integer price1, Integer price2) {
		return houseDao.getRows(did, sid, tid, title, price1, price2);
	}

	
	//admin用方法
	@Override
	public List<House> getHousesByDistrictId(int districtId) {
		return houseDao.getHousesByDistrictId(districtId);
	}

	@Override
	public List<House> getAllHouses() {
		
		return houseDao.getAllHouses();
	}

	@Override
	//未完成
	public void deleteViolationHouses(int id) {
		houseDao.deleteViolationHouses(id);
	}

	@Override
	public List<House> getUseridHouses(Integer id,Integer startPage,Integer pageSize) {
		return houseDao.getUseridHouses(id,startPage,pageSize);
	}

	@Override
	public int getUseridRows(int id) {
		return houseDao.getUseridRows(id);
	}

	@Override
	public void updateHouse(House house,Photo photo) {
		houseDao.updateHouse(house);
		photoDao.updatePhoto(photo);
	}
	

}
